/*
 * ZBrowser is an embeddable browser component.
 * Copyright (C) Author: Gangadhar Nagesh Metla (Novell, Inc.)
 * nmetla74@gmail.com 
 * Version 1.0
 * 1/3/2009
 * Filename BundlePropDialog.java
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package com.novell.zenworks.agent.zbrowser.cmddialogs;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.rmi.RemoteException;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTree;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.border.TitledBorder;

import com.novell.zenworks.agent.common.Paths;
import com.novell.zenworks.agent.zbrowser.ZBrowser;
import com.novell.zenworks.zicon.common.dialogs.IBundlePropData;
import com.novell.zenworks.zicon.common.dialogs.IHelpContacts;
import com.novell.zenworks.zicon.common.dialogs.IScheduleInfo;
import com.novell.zenworks.zicon.common.dialogs.ISysRequirements;

/**
 * The application's main frame.
 */
public class BundlePropDialog extends JDialog implements KeyListener, MouseListener
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private Font bfont = new Font("Trebuchet MS", Font.BOLD, 12);
    private Font tfont = new Font("Trebuchet MS", Font.PLAIN, 12);
    private Font font = new Font("Trebuchet MS", Font.PLAIN, 11);
    private Font blfont = new Font("Trebuchet MS", Font.BOLD, 11);
    
    private JLabel assignmentLabel;
    private JLabel scheduleLabel;
    private JScrollPane scheduleScroll;
    private JTextArea scheduleText;
    private JLabel bundleName;
    private JPanel buttonPanel;
    private JTable contactsTable;
    private JTextArea description;
    private JLabel descriptionLabel;
    private JScrollPane descriptionScrollPane;
    private JCheckBox desktopCheck;
    private JLabel folder;
    private JLabel folderLabel;
    private JPanel generalTabPanel;
    private JLabel guid;
    private JLabel guidLabel;
    private JPanel helpContactsPanel;
    private JPanel mainPanel;
    private JButton okButton;
    private JLabel productTitleLabel;
    private JCheckBox quickLaunchCheck;
    private JCheckBox runOnceBundleCheck;
    private JScrollPane scheduleScrollPanel;
    private JPanel scheduleSubPanel;
    private JPanel shortcutPanel;
    private JCheckBox startMenuCheck;
    private JLabel statusLabel;
    private JPanel statusPanel;
    private JPanel statusTabPanel;
    private JPanel systemReqPanel;
    private JScrollPane systemReqScroll;
    private JTree systemReqTree;
    private JCheckBox systemTrayCheck;
    private JTabbedPane tabPanel;
    private JScrollPane tableScrollPanel;
    private JPanel timeSchedulesPanel;
    private JPanel titleBarPanel;
    private JLabel titlePatternLabel;
    private JLabel version;
    private JLabel versionLabel;
    private JCheckBox windowViewCheck;
    private JLabel zone;
    private JLabel zoneLabel;


    public BundlePropDialog(JFrame frame, IBundlePropData data) throws RemoteException {

        super(frame);
        initComponents(data);
    }

    private void initButtonPanel(IBundlePropData data) throws RemoteException
    {
    	GridBagConstraints gridBagConstraints;
    	buttonPanel = new JPanel();
    	okButton = new JButton();
    	
    	buttonPanel.setName("buttonPanel"); // NOI18N
        buttonPanel.setLayout(new GridBagLayout());
        
        okButton.setFont(tfont);
        okButton.setText(data.getOKText());
        okButton.setMaximumSize(new Dimension(150, 25));
        okButton.setMinimumSize(new Dimension(75, 25));
        okButton.setName("okButton"); // NOI18N
        okButton.addKeyListener(this);
        okButton.addMouseListener(this);
        
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.anchor = GridBagConstraints.NORTHEAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.ipadx = 25;
        gridBagConstraints.insets = new Insets(0, 0, 0, 0);
        buttonPanel.add(okButton, gridBagConstraints);

        
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 10, 5, 10);
        mainPanel.add(buttonPanel, gridBagConstraints);
    }
    
    private void initMainPanel(IBundlePropData data) throws RemoteException
    {
    	mainPanel = new JPanel();
    	mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setLayout(new GridBagLayout());
    	initTitleBarPanel(data);    	
    	initTabPanel(data);
    	initButtonPanel(data);   	
    }
    
    private void initTabPanel(IBundlePropData data) throws RemoteException
    {
    	GridBagConstraints gridBagConstraints;
    	tabPanel = new JTabbedPane();
    	tabPanel.setName("tabPanel"); // NOI18N
        tabPanel.setOpaque(true);
        tabPanel.setFont(bfont);
        
    	initGeneralTabPanel(data);
    	initStatusTabPanel(data);
    	initHelpContactsPanel(data);
    	initSystemReqsPanel(data);
    	initTimeSchedulesPanel(data);
    	
    	gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new Insets(0, 10, 0, 10);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        mainPanel.add(tabPanel, gridBagConstraints);
    }
    
    private void initGeneralTabPanel(IBundlePropData data) throws RemoteException
    {
    	GridBagConstraints gridBagConstraints;
    	generalTabPanel = new JPanel();
        bundleName = new JLabel();
        zoneLabel = new JLabel();
        zone = new JLabel();
        guid = new JLabel();
        guidLabel = new JLabel();
        versionLabel = new JLabel();
        folderLabel = new JLabel();
        version = new JLabel();
        folder = new JLabel();
        descriptionScrollPane = new JScrollPane();
        description = new JTextArea();
        descriptionLabel = new JLabel();
        
        generalTabPanel.setFont(font);
        generalTabPanel.setName("generalTabPanel"); // NOI18N
        generalTabPanel.setLayout(new GridBagLayout());

        bundleName.setFont(blfont); // NOI18N
        bundleName.setText(data.getName());
        bundleName.setName("bundleName"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 10, 0, 5);
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(bundleName, gridBagConstraints);

        zoneLabel.setFont(blfont); // NOI18N
        zoneLabel.setText(data.getZoneLabel());
        zoneLabel.setName("zoneLabel"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.ipadx = 60;
        gridBagConstraints.gridwidth = gridBagConstraints.gridheight = 1;
        gridBagConstraints.insets = new Insets(5, 10, 0, 5);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(zoneLabel, gridBagConstraints);

        zone.setFont(font); // NOI18N
        zone.setText(data.getZone());
        zone.setName("zone"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = gridBagConstraints.gridheight = 1;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.ipadx = 150;
        gridBagConstraints.insets = new Insets(5, 0, 0, 5);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(zone, gridBagConstraints);

        guid.setFont(font); // NOI18N
        guid.setText(data.getGuid());
        guid.setName("guid"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 0, 0, 10);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(guid, gridBagConstraints);

        guidLabel.setFont(blfont); // NOI18N
        guidLabel.setText(data.getGuidLabel());
        guidLabel.setName("guidLabel"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 10, 0, 5);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(guidLabel, gridBagConstraints);

        versionLabel.setFont(blfont); // NOI18N
        versionLabel.setText(data.getVersionLabel());
        versionLabel.setName("versionLabel"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 10, 0, 5);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(versionLabel, gridBagConstraints);

        folderLabel.setFont(blfont); // NOI18N
        folderLabel.setText(data.getFolderLabel());
        folderLabel.setName("folderLabel"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 10, 0, 5);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(folderLabel, gridBagConstraints);

        version.setFont(font); // NOI18N
        version.setText(data.getVersion()); // NOI18N
        version.setName("version"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 0, 0, 10);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(version, gridBagConstraints);

        folder.setFont(font); // NOI18N
        folder.setText(data.getFolder()); // NOI18N
        folder.setName("folder"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 0, 0, 10);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(folder, gridBagConstraints);

        descriptionScrollPane.setName("descriptionScrollPane"); // NOI18N

        description.setFont(font); // NOI18N
        description.setColumns(20);
        description.setEditable(false);
        description.setLineWrap(true);
        description.setText(data.getDesc()); // NOI18N
        description.setWrapStyleWord(true);
        description.setEditable(false);
        description.setName("description"); // NOI18N
        descriptionScrollPane.setViewportView(description);

        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 10;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(0, 10, 5, 10);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        gridBagConstraints.weighty = 1.0;
        generalTabPanel.add(descriptionScrollPane, gridBagConstraints);

        descriptionLabel.setFont(blfont); // NOI18N
        descriptionLabel.setText(data.getDescriptionLabel());
        descriptionLabel.setName("descriptionLabel"); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(5, 10, 5, 5);
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        generalTabPanel.add(descriptionLabel, gridBagConstraints);
        generalTabPanel.setToolTipText(data.getGeneralToolTipText());

        tabPanel.addTab(data.getGeneralTabText(), generalTabPanel);
    }
    
    private void initStatusTabPanel(IBundlePropData data) throws RemoteException
    {
    	GridBagConstraints gridBagConstraints;
    	 statusTabPanel = new JPanel();
    	 runOnceBundleCheck = new JCheckBox();
         statusPanel = new JPanel();
         assignmentLabel = new JLabel();
         statusLabel = new JLabel();
         shortcutPanel = new JPanel();
         desktopCheck = new JCheckBox();
         windowViewCheck = new JCheckBox();
         startMenuCheck = new JCheckBox();
         quickLaunchCheck = new JCheckBox();
         systemTrayCheck = new JCheckBox();  
         
         statusTabPanel.setName("statusTabPanel"); // NOI18N
         statusTabPanel.setLayout(new GridBagLayout());

         runOnceBundleCheck.setFont(font); // NOI18N
         runOnceBundleCheck.setSelected(data.isRunOnceBundle());
         runOnceBundleCheck.setText(data.getRunOnceLabel());
         runOnceBundleCheck.setName("runOnceBundleCheck"); // NOI18N
         runOnceBundleCheck.setEnabled(false);
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 2;
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.weighty = 1.0;
         gridBagConstraints.insets = new Insets(0, 5, 0, 0);
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         statusTabPanel.add(runOnceBundleCheck, gridBagConstraints);

         statusPanel.setBorder(BorderFactory.createTitledBorder(null, data.getBundleOnDevice(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, blfont, Color.BLACK));
         statusPanel.setName("statusPanel"); // NOI18N
         statusPanel.setLayout(new GridBagLayout());

         assignmentLabel.setFont(font); // NOI18N
         assignmentLabel.setText(data.getStatus()); // NOI18N
         assignmentLabel.setName("assignmentLabel"); // NOI18N
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.insets = new Insets(5, 5, 5, 5);
         statusPanel.add(assignmentLabel, gridBagConstraints);

         statusLabel.setFont(font); // NOI18N
         statusLabel.setText(data.getStatusDesc()); // NOI18N
         statusLabel.setName("statusLabel"); // NOI18N
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 1;
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.weighty = 1.0;
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         gridBagConstraints.insets = new Insets(5, 5, 5, 5);
         statusPanel.add(statusLabel, gridBagConstraints);

         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         gridBagConstraints.insets = new Insets(10, 5, 5, 5);
         statusTabPanel.add(statusPanel, gridBagConstraints);

         shortcutPanel.setBorder(BorderFactory.createTitledBorder(null, data.getShortcutLocation(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, blfont, Color.BLACK));
         shortcutPanel.setName("shortcutPanel"); // NOI18N
         shortcutPanel.setLayout(new GridBagLayout());

         
         desktopCheck.setFont(font); // NOI18N
         desktopCheck.setText(data.getDesktopText());
         desktopCheck.setName("desktopCheck"); // NOI18N
         desktopCheck.setSelected(data.isDesktopSC());
         desktopCheck.setEnabled(false);
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 0;
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.weighty = 1.0;
         shortcutPanel.add(desktopCheck, gridBagConstraints);
         
         quickLaunchCheck.setFont(font); // NOI18N
         quickLaunchCheck.setText(data.getQuickLaunchText()); // NOI18N
         quickLaunchCheck.setName("quickLaunchCheck"); // NOI18N
         quickLaunchCheck.setSelected(data.isQuickLaunchSC());
         quickLaunchCheck.setEnabled(false);
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.weighty = 1.0;
         gridBagConstraints.gridx = 1;
         gridBagConstraints.gridy = 0;        
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         shortcutPanel.add(quickLaunchCheck, gridBagConstraints);
         
         startMenuCheck.setFont(font); // NOI18N
         startMenuCheck.setText(data.getStartMenuText());
         startMenuCheck.setName("startMenuCheck"); // NOI18N
         startMenuCheck.setSelected(data.isStartMenuSC());
         startMenuCheck.setEnabled(false);
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.weighty = 1.0;
         gridBagConstraints.gridx = 2;
         gridBagConstraints.gridy = 0; 
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         shortcutPanel.add(startMenuCheck, gridBagConstraints);
         
         systemTrayCheck.setFont(font); // NOI18N
         systemTrayCheck.setText(data.getSystemTrayText()); // NOI18N
         systemTrayCheck.setName("systemTrayCheck"); // NOI18N
         systemTrayCheck.setSelected(data.isSystemTraySC());
         systemTrayCheck.setEnabled(false);
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 1;
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.weighty = 1.0;
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         shortcutPanel.add(systemTrayCheck, gridBagConstraints);
         
         
         windowViewCheck.setFont(font); // NOI18N
         windowViewCheck.setText(data.getExplorerViewText());
         windowViewCheck.setName("windowViewCheck"); // NOI18N
         windowViewCheck.setSelected(data.isWindowViewSC());
         windowViewCheck.setEnabled(false);
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.weighty = 1.0;
         gridBagConstraints.gridx = 1;
         gridBagConstraints.gridy = 1;
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         shortcutPanel.add(windowViewCheck, gridBagConstraints);

         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 1;
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.weighty = 1.0;
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         gridBagConstraints.insets = new Insets(5, 5, 5, 5);
         statusTabPanel.add(shortcutPanel, gridBagConstraints);

         tabPanel.addTab(data.getStatusTabText(), statusTabPanel);
    }
    
    private void initHelpContactsPanel(IBundlePropData data) throws RemoteException
    {
    	 helpContactsPanel = new JPanel();
    	 tableScrollPanel = new JScrollPane();
         contactsTable = new JTable();
         
         helpContactsPanel.setFont(font);
         helpContactsPanel.setName("helpContactsPanel"); // NOI18N
         helpContactsPanel.setLayout(new GridLayout(1, 0));

         tableScrollPanel.setName("tableScrollPanel"); // NOI18N

         contactsTable.setFont(font);
         contactsTable.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
         
         List<IHelpContacts> helpContacts = data.getHelpContacts();
         Object[][] contacts = new Object[helpContacts.size()][3];
         
         for(int i=0; i<helpContacts.size(); i++)
         {
        	 contacts[i][0] = helpContacts.get(i).getName();
        	 contacts[i][1] = helpContacts.get(i).getPhone();
        	 contacts[i][2] = helpContacts.get(i).getEmail();
         }

         contactsTable.setModel(new DefaultTableModel(
            contacts,
             new String [] {
                 data.getNameText(), data.getPhoneText(), data.getEmailText()
             }
         ) {
             /**
			 * 
			 */
			private static final long serialVersionUID = 1L;
			boolean[] canEdit = new boolean [] {
                 false, false, false
             };

             public boolean isCellEditable(int rowIndex, int columnIndex) {
                 return canEdit [columnIndex];
             }
         });
         contactsTable.setGridColor(Color.BLACK);
         contactsTable.setName("contactsTable"); // NOI18N
         tableScrollPanel.setViewportView(contactsTable);

         helpContactsPanel.add(tableScrollPanel);

         tabPanel.addTab(data.getHelpTabText(), helpContactsPanel);
    }
    
    private void initSystemReqsPanel(IBundlePropData data) throws RemoteException
    {
    	 if(data.getSysReqs().size() > 0)
    	 {
    		 systemReqPanel = new JPanel();
    		 systemReqScroll = new JScrollPane();
    		 

    		 systemReqPanel.setFont(font);
    		 systemReqPanel.setName("systemReqPanel"); // NOI18N
    		 systemReqPanel.setLayout(new GridLayout(1, 0));

    		 systemReqScroll.setName("systemReqScroll"); // NOI18N

    		 List<ISysRequirements> sysReqs = data.getSysReqs();
    		 DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
    		 
    		 for(int i = 0; i < sysReqs.size(); i++)
                 addChildTreeNode(sysReqs.get(i), root);
    		 
    		 systemReqTree = new JTree(root);
    		 systemReqTree.setName("systemReqTree"); // NOI18N
    		 systemReqTree.setShowsRootHandles(true);
    		 systemReqTree.setEditable(false);
    		 systemReqTree.setRootVisible(false);
    		 expandTree();
    		 systemReqScroll.setViewportView(systemReqTree);

    		 systemReqPanel.add(systemReqScroll);

    		 tabPanel.addTab(data.getSysReqTabText(), systemReqPanel); // NOI18N
    	 }
    }
    
    
    private void expandTree() 
    {
        if(systemReqTree != null)
        {
            for(int i = 0; i < systemReqTree.getRowCount(); i++)
            {
            	systemReqTree.expandRow(i);
        	}	
        }		
	}

	private void addChildTreeNode(ISysRequirements req, DefaultMutableTreeNode parentNode) throws RemoteException
    {    
    	DefaultMutableTreeNode node = null;
    	if(req.getColor().equals(ISysRequirements.REQ_COLOR.RED))
    	{
    	    node = new DefaultMutableTreeNode("<html><font color=red>"+req.getRequirement()+"</font></html>");
    	}
    	else
    	{
    		node = new DefaultMutableTreeNode(req.getRequirement());
    	}
    	parentNode.add(node);
    	for(int i = 0; i < req.getChildRequirements().size(); i++)
    	{
    		addChildTreeNode(req.getChildRequirements().get(i), node);
    	}
    }
    
    private void initTimeSchedulesPanel(IBundlePropData data) throws RemoteException
    {
    	List<IScheduleInfo> scheduleInfo = data.getScheduleData();
    	if(scheduleInfo.size() > 0)
    	{
    		GridBagConstraints gridBagConstraints;
    		timeSchedulesPanel = new JPanel();
    		scheduleScrollPanel = new JScrollPane();
    		scheduleSubPanel = new JPanel();

    		timeSchedulesPanel.setName("timeSchedulesPanel"); // NOI18N
    		timeSchedulesPanel.setLayout(new GridBagLayout());

    		scheduleScrollPanel.setName("scheduleScrollPanel"); // NOI18N

    		scheduleSubPanel.setName("scheduleSubPanel"); // NOI18N
    		scheduleSubPanel.setLayout(new GridBagLayout());
    		
    		String[][] schedules = new String[scheduleInfo.size()][2];

    		int gridLoc = 0; //for calculation of grid location.
            for(int i=0; i<scheduleInfo.size(); i++)
            {
            	scheduleLabel = new JLabel();
        		scheduleScroll = new JScrollPane();
        		scheduleText = new JTextArea();
        		
            	schedules[i][0] = scheduleInfo.get(i).getType();
            	schedules[i][1] = scheduleInfo.get(i).getSchedule();            	
            	
            	scheduleLabel.setFont(blfont);
        		scheduleLabel.setText(data.getScheduleAction() + ZBrowser.rm.getString(scheduleInfo.get(i).getType()));
        		scheduleLabel.setName("scheduleLabel"); // NOI18N
        		gridBagConstraints = new GridBagConstraints();
        		gridBagConstraints.gridx = 0;
        		gridBagConstraints.gridy = gridLoc;
        		gridBagConstraints.fill = GridBagConstraints.BOTH;
        		gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        		gridBagConstraints.weightx = 1.0;
        		gridBagConstraints.weighty = 1.0;
        		gridBagConstraints.insets = new Insets(10, 10, 0, 10);
        		scheduleSubPanel.add(scheduleLabel, gridBagConstraints);    		

        		scheduleScroll.setName("scheduleScroll"); // NOI18N

        		scheduleText.setFont(font);
        		scheduleText.setColumns(20);
        		scheduleText.setLineWrap(true);
        		scheduleText.setText(scheduleInfo.get(i).getSchedule());
        		scheduleText.setWrapStyleWord(true);
        		scheduleText.setEditable(false);
        		scheduleText.setName("scheduleText"); // NOI18N
        		scheduleScroll.setViewportView(scheduleText);
        		scheduleScroll.setVisible(true);

        		gridBagConstraints = new GridBagConstraints();
        		gridBagConstraints.gridx = 0;
        		gridBagConstraints.gridy = ++gridLoc;
        		gridBagConstraints.weightx = 1.0;
        		gridBagConstraints.weighty = 1.0;
        		gridBagConstraints.insets = new Insets(5, 10, 10, 10);
        		gridBagConstraints.fill = GridBagConstraints.BOTH;
        		gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        		scheduleSubPanel.add(scheduleScroll, gridBagConstraints);
        		
        		++gridLoc;
            }
    		scheduleScrollPanel.setViewportView(scheduleSubPanel);

    		gridBagConstraints = new GridBagConstraints();
    		gridBagConstraints.fill = GridBagConstraints.BOTH;
    		gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
    		gridBagConstraints.weightx = 1.0;
    		gridBagConstraints.weighty = 1.0;
    		gridBagConstraints.insets = new Insets(5, 10, 5, 10);
    		timeSchedulesPanel.add(scheduleScrollPanel, gridBagConstraints);

    		tabPanel.addTab(data.getScheduleTabText(), timeSchedulesPanel);
    	}
    }

	private void initTitleBarPanel(IBundlePropData data)
    {
    	GridBagConstraints gridBagConstraints;
    	 titleBarPanel = new JPanel();
         productTitleLabel = new JLabel();
         titlePatternLabel = new JLabel();
         
         titleBarPanel.setName("titleBarPanel"); // NOI18N
         titleBarPanel.setOpaque(false);
         titleBarPanel.setPreferredSize(new Dimension(210, 51));
         titleBarPanel.setLayout(new GridBagLayout());

         productTitleLabel.setIcon(new ImageIcon(Paths.RESOURCE_DIR + File.separator + "images" + File.separator + "product_title.gif")); // NOI18N
         productTitleLabel.setText("");
         productTitleLabel.setName("productTitleLabel"); // NOI18N
         productTitleLabel.setOpaque(true);
         productTitleLabel.setPreferredSize(new Dimension(180, 26));
         titleBarPanel.add(productTitleLabel, new GridBagConstraints());

         titlePatternLabel.setIcon(new ImageIcon(Paths.RESOURCE_DIR + File.separator + "images" + File.separator + "header_background.gif")); // NOI18N
         titlePatternLabel.setText("");
         titlePatternLabel.setMinimumSize(new Dimension(125, 26));
         titlePatternLabel.setName("titlePatternLabel"); // NOI18N
         titlePatternLabel.setOpaque(true);
         titlePatternLabel.setPreferredSize(new Dimension(250,26));
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.gridx = 1;
         gridBagConstraints.gridy = 0;
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.ipadx = 92;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         titleBarPanel.add(titlePatternLabel, gridBagConstraints);
         
         gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.gridx = 1;
         gridBagConstraints.gridy = 0;
         gridBagConstraints.weightx = 1.0;
         gridBagConstraints.insets = new Insets(5, 5, 5, 5);
         gridBagConstraints.fill = GridBagConstraints.BOTH;
         gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
         mainPanel.add(titleBarPanel, gridBagConstraints);
    }
    
    private void initComponents(IBundlePropData data) throws RemoteException 
    {
        initMainPanel(data);
        this.add(mainPanel);
        this.addWindowListener(new WindowListener(){
			public void windowActivated(WindowEvent e) {}

			public void windowClosed(WindowEvent e) {}

			public void windowClosing(WindowEvent e) 
			{
				e.getWindow().dispose();
				ZBrowser.removeBundlePropertiesDialogEntry(guid.getText());
			}

			public void windowDeactivated(WindowEvent e) {}

			public void windowDeiconified(WindowEvent e) {}

			public void windowIconified(WindowEvent e) {}

			public void windowOpened(WindowEvent e) {}}
        );
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }

	public void keyPressed(KeyEvent e) 
	{
		if(e.getKeyCode() == KeyEvent.VK_ENTER)
        {
            this.dispose();
            ZBrowser.removeBundlePropertiesDialogEntry(guid.getText());
        }		
	}

	public void keyReleased(KeyEvent e) {}

	public void keyTyped(KeyEvent e) {}

	public void mouseClicked(MouseEvent e) 
	{
	    this.dispose();
	    ZBrowser.removeBundlePropertiesDialogEntry(guid.getText());
	}

	public void mouseEntered(MouseEvent e) {}

	public void mouseExited(MouseEvent e) {}

	public void mousePressed(MouseEvent e) {}

	public void mouseReleased(MouseEvent e) {}
	
	public void requestFocusOnOkButton()
	{
		okButton.requestFocusInWindow();
	}
	
	public void setBundleIcon(String iconPath)
	{
		if(iconPath != null && iconPath.length() > 1)
        {
        	ImageIcon icon = new ImageIcon(iconPath);
        	icon.setImageObserver(bundleName);
        	bundleName.setIcon(icon);
        }
        else
        {
            bundleName.setIcon(new ImageIcon(Paths.RESOURCE_DIR + File.separator + "images" + File.separator + "zicon" + File.separator + "nal_icon.png"));  
        }
		bundleName.setIconTextGap(4);
    	bundleName.revalidate();
    	this.validate();
	}
    
}
